﻿///<reference path="~/Scripts/jquery-1.8.2.min.js" />
///<reference path="~/Scripts/jQuery.tmpl.js" />

var newsBinder = function () {
    var templateLocation = '/Templates/',
    bind = function (newsDiv, data, renderer) {
        $.get(templateLocation + 'News.html',
        function (templates) {

            $('body').append(templates);

            var newsTemplates = [
                tmpl('News', 'Lite', data),
                tmpl('News', 'Full', data),
            ];
            newsDiv.data().templates = newsTemplates;
            newsDiv.data().newsData = data;
            renderer(newsDiv);
        });
    },

    tmpl = function (typeName, size, data) {
        var template = $('#' + typeName + 'Template_' + size);
        if (data != null) {
            return template.templ(data);
        }
        else {
            return template.html();
        }
    };

    return {
        Bind: bind
    };
} ();